
<!DOCTYPE html>
<html>
	<head>
		<title>商品表-添加/修改</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<!-- 所有的 css js 资源 -->
		<link rel="stylesheet" href="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
		<link rel="stylesheet" href="../../static/sa.css"> 
		<script src="https://unpkg.com/vue@2.6.10/dist/vue.js"></script>
		<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
		<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
		<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
		<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
		<script src="https://unpkg.com/wangeditor@4.7.8/dist/wangEditor.min.js"></script>
		<script src="../../static/sa.js"></script>
		<script src="../../static/kj/upload-util.js"></script>
		<style type="text/css">
			.c-panel .el-form .c-label{width: 7em !important;}
			.c-panel .el-form .el-input, .c-panel .el-form .el-textarea__inner{width: 250px;}
			/*  普通文本和富文本一起变长  */
			.c-panel .el-form .el-input, .c-panel .el-form .el-textarea__inner{width: 800px;}
			.c-item-mline{width: 800px;}
			.el-table__body-wrapper{min-height: 0px;}
			
			
			/* .c-item .image-box{padding-bottom: -20px;} */
			.el-select__tags-text{color: #1890FF; }
			.sk-fox{border: 1px #eee solid; padding: 5px 14px; margin-top: 8px;}
			.sk-name{font-weight: bold;}
			/* 规格值 */
			.sku-box .el-tag{border-radius: 1px; margin-right: 5px;}
			/* .sku-box .el-input-group__append{padding: 0 10px;} */
			.sku-box .el-input-group__prepend,.sku-box .el-input-group__append{padding: 0 10px; border-radius: 1px !important; color: #666;}
			.not-values-tips{color: #aaa; margin-right: 14px;}
			.del-r{margin-left: 10px; }
			.sv-name{/* white-space: nowrap; *//* word-break:keep-all; */ }
			.svgao{color: #409EFF; font-weight: bold;}
			.small-input{width: 85px !important;}
			
		</style>
	</head>
	<body>
		<div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
			<!-- ------- 内容部分 ------- -->
			<div class="s-body">
				<div class="c-panel">
					<div class="c-title">日程添加</div>
					<el-form v-if="m">
						<!-- no字段： m.id - 记录id -->
						<div class="c-item br">
							<label class="c-label">标题：</label>
							<el-input v-model="m.title"></el-input>
						</div>
						<div class="c-item br">
							<label class="c-label">会议类型：</label>
							<el-select v-model="m.meeting_id">
								<!-- <el-option label="请选择" :value="0" disabled></el-option> -->
								<el-option v-for="item in meetingList" :label="item.name" :value="item.id" :key="item.id"></el-option>
							</el-select>
						</div>
						<div class="c-item br">
							<label class="c-label">会议地点：</label>
							<el-input v-model="m.address"></el-input>
						</div>
						<sa-item type="date" name="开始日期" v-model="m.begin_time" br></sa-item>
						<sa-item type="date" name="结束日期" v-model="m.end_time" br></sa-item>
						<sa-item type="textarea" name="内容" v-model="m.content" br></sa-item>
						<div style="clear: both;"></div>
						<div class="c-item br">
							<label class="c-label">日程状态：</label>
							<el-radio-group v-model="m.is_private">
								<el-radio-button :label="1">公开</el-radio-button>
								<el-radio-button :label="2">私有</el-radio-button>
							</el-radio-group>
						</div>
						<!-- date-create字段： m.create_time - 创建日期 -->
						<!-- date-update字段： m.update_time - 更新日期 -->
						<div class="c-item br s-ok">
							<label class="c-label"></label>
							<el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
						</div>
					</el-form>
				</div>
			</div>
			<!-- ------- 底部按钮 ------- -->
			<div class="s-foot">
				<el-button type="primary" @click="ok()">确定</el-button>
				<el-button @click="sa.closeCurrIframe()">取消</el-button>
			</div>
		</div>
        <script>
			
			var app = new Vue({
				components: {
					"sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),				// logo 
				},
				el: '.vue-box',
				data: {
					id: sa.p('id', 0),		// 获取超链接中的id参数（0=添加，非0=修改） 
					m: null,		// 实体对象 
					meetingList:[],
				},
				methods: {
					
					// 创建一个 默认Model 
					createModel: function() {
						return {
							//id: 0,		// 记录id 
							title: '',		// 会议标题
							meeting_id: '',		// 会议类型 
							address: '',		// 会议地址 
							begin_time:'',		//会议开始时间
							end_time:'',		//会议结束时间
							content:'',			//会议内容
							is_private: 1
						}
					},
					initModel: function(m) {
						this.m = m;
						
					},
					// 表单验证
					submitCheck: function() {
						var m = this.m;		// 获取 m对象 
						// sa.checkNull(m.id, '请输入记录id');
						sa.checkNull(m.title, '请输入会议标题');
						sa.checkNull(m.meeting_id, '请输入会议类型');
						sa.checkNull(m.address, '请输入会议地址');
						sa.checkNull(m.begin_time, '请输入开始时间');
						sa.checkNull(m.end_time, '请输入会议结束时间');
						sa.checkNull(m.content, '请输入会议内容');
						sa.checkNull(m.is_private, '请输入日程状态');
					},
					// 提交数据 
					ok: function(){
						// 验证 
						var m = this.m;
						this.submitCheck();
						
						if(this.id <= 0) {	// 添加
							sa.ajax('/api/schedule/v1/add', m, function(res){
								sa.alert('增加成功', this.clean); 
							}.bind(this));
						} else {	// 修改
							sa.ajax2('/api/schedule/v1/update', m, function(res){
								sa.alert('修改成功', this.clean);
							}.bind(this));
						}
					},
					// 添加/修改 完成后的动作
					clean: function() {
						if(this.id == 0) {
							console.log('数据为：', this.m);
							layer.alert(JSON.stringify(this.m), {title: '数据为：'});
							// 打开下面的注释，可直接在添加成功后，清空数据 
							// this.m = this.createModel();
							// this.$nextTick(function() {
							// 	create_editor('');	// 清空富文本
							// 	this.specKeyList = [];
							// 	this.f5Spec();
							// }.bind(this))
						} else {
							parent.app.f5();		// 刷新父页面列表
							sa.closeCurrIframe();	// 关闭本页 
						}
					},
					
				},
				mounted: function(){
					var that = this;
					$.ajax({
						url:"http://127.0.0.1:8081/api/schedule/v1/meetinglist",
						type:'POST',
						dataType:'json',
						timeout:3000,
						success:function(res) {
							console.log(res.data)
							that.meetingList = res.data;
						},
						error:function(){
							alert("服务器繁忙");
						}
					})
					// 初始化数据 
					if(this.id <= 0) {	
						this.initModel(this.createModel());
					} else {	
						sa.ajax2('/SerGoods/getById?id=' + this.id, function(res) {
							this.initModel(res.data);
							// 加载规格列表 (默认为空) 
							this.specList = [];
						}.bind(this))
					}
				
				}
			})
			
		</script>
	</body>
</html>